<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改基础信息</title>
</head>
<body>
<div id="baseData">
    <p>
        开&nbsp;&nbsp;户&nbsp;&nbsp;银&nbsp;&nbsp;行:&nbsp;<input type="text" v-model="showData.bankName">
    </p>
    <p>
        开&nbsp;&nbsp;户&nbsp;&nbsp;账&nbsp;&nbsp;号:&nbsp;<input type="text" v-model="showData.bankAccount">
    </p>
    <p>
        注册固定电话:&nbsp;<input type="text" v-model="showData.phone">
    </p>
    <p>
        注册场所地址:&nbsp;<input type="text" v-model="showData.address">
    </p>
    <input type="button" value="保存" @click="saveBaseData">&nbsp;
    <input type="button" value="返回" @click="returnPages">


</div>
<script src="assets/js/vue.js"></script>
<script src="assets/js/axios.min.js"></script>
<script>
    const baseData = new Vue({
        el: "#baseData",
        data: {

            showData: {
                bankName: "",
                bankAccount: "",
                phone: "",
                address: "",
            }
        },
        methods: {
            returnPages(){
                location.href="invoice-info-manage.html";
            },
            saveBaseData() {
                let _this = this;
                let formData = new FormData();
                formData.append("bankName", this.showData.bankName);
                formData.append("bankAccount", this.showData.bankAccount);
                formData.append("phone", this.showData.phone);
                formData.append("address", this.showData.address);
                let flag = _this.showData.bankName == "" || _this.showData.bankAccount == "" || _this.showData.phone == "" || _this.showData.address == "";
                if (flag) {
                    alert("请输入信息!");
                    location.href = "updateBaseData.html";
                } else {
                    axios({
                        method: "post",
                        url: "../admin/saveBaseData.bd",
                        data: formData,
                    }).then(function (response) {
                            let data = response.data;
                            if (data.code == 300) {
                                alert(data.msg);
                                location.href = "invoice-info-manage.html";
                            } else {
                                alert(data.msg);
                            }
                        }
                    )
                }
            },
        },
        created() {
            let _this = this;
            let start = location.href.lastIndexOf("=");
            let id = location.href.substring(start + 1);
            // 发请求，拿数据
            axios.get("../admin/listBaseData.bd").then(function (res) {
                console.log(res.data);
                _this.showData.bankName = res.data.value.bankName;
                _this.showData.bankAccount = res.data.value.bankAccount;
                _this.showData.phone = res.data.value.phone;
                _this.showData.address = res.data.value.address;
            });
        }
    });
</script>
</body>
</html>